#include <iostream>
#include <fstream>
#include <vector>
#include <chrono>

std::vector<int> bubble_sort(std::vector<int>& array) {
    int n = array.size();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - i - 1; j++) {
            if (array[j] > array[j + 1]) {
                std::swap(array[j], array[j + 1]);
            }
        }
    }
    return array;
}

int main() {
    std::vector<std::string> filenames = {"m1_sorted", "m2_reverse", "m3_shuffle"};
    for (const std::string& filename : filenames) {
        std::vector<int> m;
        std::ifstream file(filename + ".txt");
        std::string line;
        while (std::getline(file, line)) {
            m.push_back(std::stoi(line));
        }
        file.close();
        
        auto start = std::chrono::high_resolution_clock::now();
        bubble_sort(m);
        auto end = std::chrono::high_resolution_clock::now();
        auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
        
        std::cout << filename << " " << duration << " milliseconds" << std::endl;
    }
    
    return 0;
}